<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>

  <script>
    function sum(a, b, c) {
      return a + b + c;
    }
    //对sum这个函数的curry化
    var currySum = sum.bind(null, 1, 2);
    var res = currySum(3);
    console.log(res);
    function matchStr(reg, str) {
      return reg.test(str);
    }
    console.log(matchStr(/\s+/g, 'a b'));
    console.log(matchStr(/\s+/g, 'abc'));

    const hasWhiteSpace = matchStr.bind(null, /\s+/g);
    console.log(hasWhiteSpace('a b c'))
    console.log(hasWhiteSpace('ab '))

    const hasNum = matchStr.bind(null, /[0-9]+/g);
    console.log(hasNum('ahdj6'))

    function type(type,value) {
      Object.prototype.toString.call(value) = `[object ${type}]`
    }
    console.log(type(Array,[1,2,3,4]))
    console.log(type(Array,[1]))

    const isArray = type.bind(null,Array)
    console.log(isArray([7,8]))

  </script>
</body>

</html>